package org.example.blog.service.iml;

import org.example.blog.entity.Blog;
import org.example.blog.mapper.BlogMapper;
import org.example.blog.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogServiceImpl implements BlogService {
    @Autowired
    BlogMapper blogMapper;
    @Override
    public List<Blog> findAll(){
        //查找所有博客，调用Mapper
        return blogMapper.findAll();
    }
    @Override
    public List<Blog> findBlogsByPage(int page,int size){
        //查询分页数据
        //计算从第几行开始查询
        int offset = (page - 1) * size;
        return blogMapper.findBlogsByPage(offset,size);
    }
    @Override
    public int countBlogs(){
        return blogMapper.countBlogs();
    }
}
